using Motor_Control;
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using static AngleSensorRequest;

public class AngleSync : MonoBehaviour
{
    motorControl motorControl;
    AngleSensorRequest AglSesrR;

    Transform rightArm;
    Transform rightForeArm;
    Transform rightHand;


    private void Awake()
    {
        motorControl = GameObject.Find("GameObject").GetComponent<motorControl>();
        AglSesrR = GameObject.Find("GameObject").GetComponent<AngleSensorRequest>();

        rightArm = this.transform;
        rightForeArm = GameObject.Find("mixamorig:RightForeArm").transform;
        rightHand = GameObject.Find("mixamorig:RightHand").transform;
        AglSesrR.SetSensorAngleHandle(AngleSensorCallback);
    }
    void FixedUpdate()
    {
        // motorControl.GetMotorPos(MOTOR_ID.MOTOR_ID_2, AngleCallback);
        AglSesrR.RequstSensorAngle(SENSOR_ID.SENSOR_1);

    }

    private void AngleSensorCallback(object id,object angle1)
    {
        Debug.Log("sensor angle:" + angle1);
    }

    void AngleCallback(double angle1)
    {
        rightForeArm.localEulerAngles = new Vector3(0, (float)angle1 / 50, 0);
        Debug.Log("angle:" + angle1);
    }
}
